package com.sicau.service.serviceImpl;

import com.sicau.dao.QuestionMapper;
import com.sicau.entity.Question;
import com.sicau.service.PaperService;


import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by wzw on 2018/11/2
 */
@Service
public class PaperServiceImpl implements PaperService {
    @Autowired
    private QuestionMapper questionMapper;
    @Override
    public JSONArray getProblem() {
        List<Question> list = questionMapper.selectAll();
        JSONArray jsonArray = new JSONArray();
        for(int i =0;i<list.size();i++){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("question",list.get(i));
            jsonArray.add(jsonObject);
        }
        return jsonArray;
    }
}
